package com.example.springaware;

import com.example.springaware.config.AwareConfig;
import com.example.springaware.service.AwareService;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
/**
 *
 * @author ljw
 * @date 2021/8/10 8:13
 */
@SpringBootApplication
public class SpringAwareApplication implements ApplicationRunner {

    public static void main(String[] args) {
        SpringApplication.run(SpringAwareApplication.class, args);
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
        context.register(AwareConfig.class);
        context.refresh();
        AwareService awareService = context.getBean(AwareService.class);
        awareService.outputResult();
        context.close();

    }
}
